function logout() {
    $.ajax({
        url: '/logout',
        method: "post",
        dataType: 'json',
        success: function (data) {
            if (data.code == 0) {
                layer.msg(data.msg);
                setTimeout(function () {
                    window.location.href = '/';
                }, 1000);
            }
        }
    })

}

$('#change').on('click', function () {

    layer.open({
        type: 1,
        title: '修改密码',
        maxmin: true,
        shadeClose: true, //点击遮罩关w闭层
        area: ['300px', '220px'],
        content: $("#pwd"),
        btn: ['修改'],
        btnAlign: 'c',
        yes: function (index, layero) {

            var oldpwd = $('input[name="password1"]').val();
            var newpwd = $('input[name="password2"]').val();
            $.ajax({
                url: '/change',
                method: "post",
                data: {oldpwd: oldpwd, newpwd: newpwd},
                dataType: 'json',
                success: function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg);
                        $.ajax({
                            url: '/logout',
                            method: "post",
                            dataType: 'json',
                            success: function (data) {
                                layer.closeAll("page");
                                setTimeout(function () {

                                    window.location.reload();
                                }, 1000);


                            }
                        })
                    }
                    if (data.code == -1) {
                        layer.msg(data.msg);

                    }
                }
            })
        },
        cancel: function () {
            // window.location.reload();

            //return false 开启该代码可禁止点击该按钮关闭
        }

    });
});